package org.yf.samples.util;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.yf.samples.model.ExamTestVO;

public class TestUtils {

	public static boolean checkSubjectScoreAndCount(Integer totalTestScore, Integer totalTestCount,
			Map<Integer, Integer> testTypeScoreMap) {
		return false;
	}

	public static Map<Integer, Integer> getTestCountByScore(Integer totalTestCount,
			Map<Integer, Integer> testTypeScoreMap) {
		Map<Integer, Integer> testTypeCountMap = new HashMap<Integer, Integer>();
		int d = 8, s = 4;
		for(Integer key : testTypeScoreMap.keySet()){
			if(testTypeScoreMap.get(key) == 5){
				testTypeCountMap.put(key, d);
			}else if(testTypeScoreMap.get(key) == 15){
				testTypeCountMap.put(key, s);
			}
		}
		return testTypeCountMap;
	}

	public static List<Integer> getRandomTestIdList(List<ExamTestVO> testList, Integer count) {
		List<Integer> randomTestList = new ArrayList<Integer>();
		int size = testList.size();
		Collections.shuffle(testList);
		if(size > count){
			for(int i = 0; i < count; i++){
				randomTestList.add(testList.get(i).getId());
			}
			return randomTestList;
		}else if(size == count){
			for(ExamTestVO vo : testList){
				randomTestList.add(vo.getId());
			}
			return randomTestList;
		}else{
			return null;
		}
	}
}
